home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / Powerpoint.vbs < prev    next >
Encoding:
Text File  |  2005-01-29  |  7.4 KB  |  230 lines

  1. 'FMA Script Framework Plugin
  2. 'Powerpoint
  3. 'Lets you control MS Powerpoint
  4.  
  5. 'TODO:
  6. '-nothing atm
  7.  
  8. Class Powerpoint
  9.  
  10. Private llist
  11. Private m_Self
  12. Private mainMenu
  13.  
  14. 'Some info about the plugin
  15. Public Property Get SHOWABLE 'Do I have a menu?
  16.   SHOWABLE    = True
  17. End Property
  18. Public Property Get TITLE 'What's my name?
  19.   TITLE      = "Powerpoint"
  20. End Property
  21. Public Property Get DESCRIPTION 'What's my purpose?
  22.   DESCRIPTION = "Lets you control Powerpoint"
  23. End Property
  24. Public Property Get AUTHOR 'Who created me?
  25.   AUTHOR      = "streawkceur (inspired by CarpeDi3m) - extended by ws"
  26. End Property
  27. Public Property Get URL 'Were can I be found? Where can you get more information?
  28.   URL = "http://fma.sourceforge.net/"
  29. End Property
  30.  
  31. 'Who am I?
  32. Public Property Let Self (s)
  33.   m_Self = s
  34.   ' Some init stuff here:
  35.   If IsEmpty(Settings(Me, "Title")) or Settings(Me, "Title") = "" Then Settings(Me, "Title") = "Microsoft PowerPoint"
  36.   If IsEmpty(Settings(Me, "Exe"))  or Settings(Me, "Exe")  = "" Then Settings(Me, "Exe")  = "C:\Program Files\Microsoft Office\Office10\Powerpnt.exe"
  37.   'keyboard shortcut to switch to the slide overview. the default is only correct for the german Powerpoint.
  38.   If IsEmpty(Settings(Me, "SlideOverviewShortcut"))  or Settings(Me, "SlideOverviewShortcut")  = "" Then Settings(Me, "SlideOverviewShortcut")  = "{ESC}%ai"
  39.   'keyboard shortcut to resume presentation with the selected slide. the default is only correct if Powerpoint shortcuts are installed
  40.   '(see http://officeone.mvps.org/ppshortcuts/ppshortcuts.html). For Powerpoint2003, "+{F5}" can be used.
  41.   If IsEmpty(Settings(Me, "ResumePresentationShortcut"))  or Settings(Me, "ResumePresentationShortcut")  = "" Then Settings(Me, "ResumePresentationShortcut")  = "{F3}"
  42.   Set mainMenu = New ManagedMenu
  43.   mainMenu.Title = TITLE
  44. End Property
  45. Public Property Get Self
  46.   Self = m_Self
  47. End Property
  48.  
  49. 'Display me. Eventually put a menu on the screen
  50. Sub Show()
  51.   '--> Init Menu
  52.   Set llist = New LinkedList
  53.   Dim bi
  54.   bi = llist.BackInserter
  55.   If PPOpen Then
  56.   bi.Item = Array("Start Show",    Self & ".StartShow")
  57.   bi.Item = Array("Resume",        Self & ".ResumeShow")
  58.   bi.Item = Array("End Show",      Self & ".EndShow")
  59.   bi.Item = Array("Prev Slide",    Self & ".PrevSlide")
  60.   bi.Item = Array("Navigate...",  Self & ".Navigate")
  61.   bi.Item = Array("Next Slide",    Self & ".NextSlide")
  62.   bi.Item = Array("Choose...",    Self & ".ChooseSlide")
  63.   bi.Item = Array("Toggle Screen", Self & ".Toggle")
  64.   bi.Item = Array("Close",        Self & ".Close")
  65.   Else
  66.   bi.Item = Array("Launch",        Self & ".Launch")
  67.   End If
  68.   mainMenu.SetList llist
  69.   mainMenu.ShowMenu
  70. End Sub
  71.  
  72. Function PPOpen
  73.   PPOpen = Shell.AppActivate(Settings(Me, "Title"))
  74. End Function
  75.  
  76. Sub Launch
  77.   If Fso.FileExists(Settings(Me, "Exe")) Then
  78.   Shell.Exec Settings(Me, "Exe")
  79.   Util.WaitForAppLoad Settings(Me, "Title"), 10000 'Give PP max. 10 secs to load
  80.   Else
  81.   Debug.ErrorMsg Self & " - Launch: File not found: " & Settings(Me, "Exe")
  82.   End If
  83.   Show
  84. End Sub
  85.  
  86. Sub Close
  87.   If PPOpen Then Shell.SendKeys "%{F4}"
  88.   Util.WaitForAppClose Settings(Me, "Title"), 10000
  89.   Show
  90. End Sub
  91.  
  92. Sub StartShow
  93.   Shell.SendKeys "{F5}"
  94.   am.Update
  95.   Navigate
  96. End Sub
  97.  
  98. Sub ResumeShow
  99.   Shell.SendKeys Settings(Me, "ResumePresentationShortcut")
  100.   am.Update
  101.   Navigate
  102. End Sub
  103.  
  104.  
  105. Sub NextSlide
  106.   Shell.SendKeys "{RIGHT}"
  107.   am.Update
  108. End Sub
  109.  
  110. Sub PrevSlide
  111.   Shell.SendKeys "{LEFT}"
  112.   am.Update
  113. End Sub
  114.  
  115.  
  116. Sub Toggle
  117.   If PPOpen Then Shell.SendKeys "."
  118.   am.Update
  119. End Sub
  120.  
  121. Sub EndShow
  122.   If PPOpen Then Shell.SendKeys "{ESC}"
  123.   am.Update
  124. End Sub
  125.  
  126. 'Navigate function allows to use all useful means to switch to the
  127. 'next/previous slide: joystick, number keys or volume control
  128. Sub Navigate
  129.   EmptyMenu.ShowMenu
  130.   am.Back = Self & ".ChooseNavigateQuit" 'Manage the menu quit by ourselves
  131.   KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".NavPrevSlide",  STATE_PRESS,  Me
  132.   KeyManager.RegisterKey KEY_JOYUP,    Self & ".NavPrevSlide",  STATE_PRESS,  Me
  133.   KeyManager.RegisterKey KEY_VOLUP,    Self & ".NavPrevSlide",  STATE_PRESS,  Me
  134.   KeyManager.RegisterKey KEY_1,        Self & ".NavPrevSlide",  STATE_PRESS,  Me
  135.   KeyManager.RegisterKey KEY_4,        Self & ".NavPrevSlide",  STATE_PRESS,  Me
  136.   KeyManager.RegisterKey KEY_7,        Self & ".NavPrevSlide",  STATE_PRESS,  Me
  137.   KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".NavNextSlide",  STATE_PRESS,  Me
  138.   KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".NavNextSlide",  STATE_PRESS,  Me
  139.   KeyManager.RegisterKey KEY_VOLDOWN,  Self & ".NavNextSlide",  STATE_PRESS,  Me
  140.   KeyManager.RegisterKey KEY_3,        Self & ".NavNextSlide",  STATE_PRESS,  Me
  141.   KeyManager.RegisterKey KEY_6,        Self & ".NavNextSlide",  STATE_PRESS,  Me
  142.   KeyManager.RegisterKey KEY_9,        Self & ".NavNextSlide",  STATE_PRESS,  Me
  143.   KeyManager.RegisterKey KEY_JOYPRESS, Self & ".QuitAndChoose",  STATE_PRESS,  Me
  144.   KeyManager.RegisterKey KEY_5,        Self & ".QuitAndChoose",  STATE_PRESS,  Me
  145.   KeyManager.RegisterKey KEY_0,        Self & ".NavigateQuit",  STATE_PRESS,  Me
  146.   KeyManager.RegisterKey KEY_ASTERIX,  Self & ".NavigateQuit",  STATE_PRESS,  Me
  147.   KeyManager.RegisterKey KEY_SHARP,    Self & ".NavigateQuit",  STATE_PRESS,  Me
  148.  
  149.   am.DlgMsgBox "Use Joystick or keys for next/prev slide, 5 to choose, 0 to quit", 0
  150. End Sub
  151.  
  152.  
  153. Sub NavigateQuit
  154.   KeyManager.DeregisterAll Me
  155.   MenuStack.Top.Quit 'Remove emtpy menu
  156. End Sub
  157.  
  158.  
  159. Sub QuitAndChoose
  160.   NavigateQuit
  161.   ChooseSlide
  162. End Sub
  163.  
  164.  
  165.  
  166. Sub NavNextSlide
  167.   Shell.SendKeys "{RIGHT}"
  168. End Sub
  169.  
  170. Sub NavPrevSlide
  171.   Shell.SendKeys "{LEFT}"
  172. End Sub
  173.  
  174.  
  175. 'Choose slide
  176. 'switches to slide overview and lets you choose another slide.
  177. 'to choose the right slide, you can either use the joystick or the number keys.
  178. 'on exit, resumes presentation
  179. Sub ChooseSlide()
  180.   Shell.SendKeys Settings(Me, "SlideOverviewShortcut")
  181.   EmptyMenu.ShowMenu
  182.   am.Back = Self & ".ChooseSlideQuit" 'Manage the menu quit by ourselves
  183.   KeyManager.RegisterKey KEY_JOYUP,    Self & ".SlideUp",    STATE_PRESS, Me
  184.   KeyManager.RegisterKey KEY_2,        Self & ".SlideUp",    STATE_PRESS, Me
  185.   KeyManager.RegisterKey KEY_JOYRIGHT, Self & ".SlideRight",  STATE_PRESS, Me
  186.   KeyManager.RegisterKey KEY_6,        Self & ".SlideRight",  STATE_PRESS, Me
  187.   KeyManager.RegisterKey KEY_JOYDOWN,  Self & ".SlideDown",  STATE_PRESS, Me
  188.   KeyManager.RegisterKey KEY_8,        Self & ".SlideDown",  STATE_PRESS, Me
  189.   KeyManager.RegisterKey KEY_JOYLEFT,  Self & ".SlideLeft",  STATE_PRESS, Me
  190.   KeyManager.RegisterKey KEY_4,        Self & ".SlideLeft",  STATE_PRESS, Me
  191.   KeyManager.RegisterKey KEY_JOYPRESS, Self & ".ChooseQuitAndNavigate", STATE_PRESS, Me
  192.   KeyManager.RegisterKey KEY_5,        Self & ".ChooseQuitAndNavigate", STATE_PRESS, Me
  193.   KeyManager.RegisterKey KEY_0,        Self & ".ChooseSlideQuit", STATE_PRESS, Me
  194.  
  195.   am.DlgMsgBox "Use Joystick or keys to select slide, 5 to continue, 0 to quit", 0
  196. End Sub
  197.  
  198. Sub ChooseSlideQuit()
  199.   Shell.SendKeys Settings(Me, "ResumePresentationShortcut")
  200. '  Shell.SendKeys "{F3}"
  201.   KeyManager.DeregisterAll Me
  202.   MenuStack.Top.Quit 'Remove emtpy menu
  203.   Navigate
  204. End Sub
  205.  
  206. Sub ChooseQuitAndNavigate()
  207.   ChooseSlideQuit
  208.   Navigate
  209. End Sub
  210.  
  211.  
  212. Sub SlideUp
  213.   Shell.SendKeys "{UP}"
  214. End Sub
  215.  
  216. Sub SlideDown
  217.   Shell.SendKeys "{DOWN}"
  218. End Sub
  219.  
  220. Sub SlideLeft
  221.   Shell.SendKeys "{LEFT}"
  222. End Sub
  223.  
  224. Sub SlideRight
  225.   Shell.SendKeys "{RIGHT}"
  226. End Sub
  227.  
  228.  
  229. End Class
  230.